/**
 * 
 */
define(function(require, exports, module) {

	var $ = require('jquery');
	require('tinymce/4.0.10/tinymce.min.js');

	tinymce.init({
		selector : 'textarea',
		theme : "modern"
	});

	exports.getRegion = function(parentId, regionType) {
		$.get("http://localhost:8088/mercy/api/region/list/parent", {
			parentId : parentId
		}, function(data) {
			alert(JSON.stringify(data));
			var i, len = data.length, html = '';
			var selectType = '';
			html += '<option>' + selectType + '</option>';

			for (i = 0; i < len; i++) {
				html += '<option value="' + data[i].id + '">' + data[i].name
						+ '</option>';
			}
			$("#region-" + regionType + "-select").empty().append(html);
		});
	};
	exports.getRegion(0, "country");

	$("#region-country-select").change(function() {
		exports.getRegion($(this).val(), "province");
		$("#countryId").val($(this).val());
	});
	$("#region-province-select").change(function() {
		exports.getRegion($(this).val(), "city");
		$("#provinceId").val($(this).val());
	});
	$("#region-city-select").change(function() {
		exports.getRegion($(this).val(), "district");
		$("#cityId").val($(this).val());
	});

});